Skip to contents

Plots QSM cylinders using the rgl library

Usage

plot_qsm(
  cylinder,
  radius = NULL,
  cyl_color = NULL,
  cyl_palette = NULL,
  cyl_sides = 8,
  cloud = NULL,
  pt_color = NULL,
  pt_size = NULL,
  axes = TRUE,
  hover = FALSE
)

Arguments

cylinder

QSM cylinder data frame

radius

Vector of cylinder radii. Defaults to modified cylinders from the cylinder data frame.

cyl_color

Optional cylinder color parameter. Colors must be a single hex color, or a vector or column of hex colors with the same length as the cylinder data frame.

cyl_palette

Optional color palette for numerical data. Palettes include: viridis, inferno, plasma, magma, cividis, and rainbow.

cyl_sides

The number of sides in the polygon cross section. Defaults to 8, but can be increased to improve visual smoothness.

cloud

Point cloud data frame where the first three columns are the x, y, and z coordinates in the same coordinate system as the QSM.

pt_color

Color of the point cloud. Defaults to black.

pt_size

Size of the points as a number. Defaults to 0.1.

axes

Show plot axes. Defaults to TRUE.

hover

Show cylinder ID and branch on mouse hover. Defaults to FALSE.

Value

A rgl QSM plot

Examples

# \donttest{

## TreeQSM Processing Chain
file <- system.file("extdata/QSM.mat", package = "rTwig")
qsm <- import_qsm(file)
#> Importing TreeQSM .mat
cylinder <- qsm$cylinder
cylinder <- update_cylinders(cylinder)
#> Updating Cylinder Ordering
#> Calculating Growth Length
#> Calculating Reverse Branch Order
cylinder <- correct_radii(cylinder, twigRad = 4.23)
#> Generating Branch Paths
#> Starting Parallel Workers
#> Correcting Branch Paths
#> Updating Cylinder Radii
#> Done!
plot_qsm(cylinder)
#> Plotting QSM
#> Creating Cylinder Meshes
#> Plotting Cylinder Meshes

## SimpleForest Processing Chain
file <- system.file("extdata/QSM.csv", package = "rTwig")
cylinder2 <- read.csv(file)
cylinder2 <- update_cylinders(cylinder2)
cylinder2 <- correct_radii(cylinder2, twigRad = 4.23)
#> Generating Branch Paths
#> Starting Parallel Workers
#> Correcting Branch Paths
#> Updating Cylinder Radii
#> Done!
plot_qsm(cylinder2)
#> Plotting QSM
#> Creating Cylinder Meshes
#> Plotting Cylinder Meshes

## All Parameters
file2 <- system.file("extdata/cloud.txt", package = "rTwig")
cloud <- read.table(file2, header = FALSE)

plot_qsm(
  cylinder,
  radius = cylinder$UnmodRadius,
  cyl_color = cylinder$GrowthLength,
  cyl_palette = "viridis",
  cyl_sides = 100,
  cloud = cloud,
  pt_color = "white",
  pt_size = 1,
  axes = FALSE,
  hover = TRUE
)
#> Plotting QSM
#> Creating Cylinder Meshes
#> Plotting Cylinder Meshes